#!/usr/bin/ruby

# AUDIO PROPERTIES
RATE = 8000
AUD_FORMAT = "ogg"

BLOCK_DUR = 1 * 60 # seconds  #FIXME
OVERLAP_DUR = 10 # seconds

SILENCE_DUR = 1.0 # seconds
THRESHOLD = 10 # percent amplitude

# FILES & DIRECTORIES
RAMO_HOME = "/opt/radio-monitor-trunk/" #FIXME

JOIN_RB = RAMO_HOME + "./join_recs.rb"
INDEX_HTML = RAMO_HOME + "./web/index.html"
PLOT_RB = RAMO_HOME + "./web/plot.rb"

RECS_DIR = '/media/data/recordings-testing/' #FIXME
DB_FILE  = RAMO_HOME + "./recs.db"

# LOG FILES
DAEMON_LOG = RAMO_HOME + "./log/daemon.log"
WEB_LOG = RAMO_HOME + "./log/web.log"

# DATABASE
START_T_COL = "start_t"
END_T_COL   = "end_t"
ACT_LEN_COL = "activity_len"
WDAY_COL    = "week_day"
DTIME_COL   = "day_time"
FNAME_COL   = "filename"
HAVE_F_COL  = "have_file"

START_T_DBI = 0
END_T_DBI   = 1
ACT_LEN_DBI = 2
WDAY_DBI    = 3
DTIME_DBI   = 4
FNAME_DBI   = 5
HAVE_F_DBI  = 6

# Recordings(start_t integer, end_t integer, activity_len integer,
#   activity_score ?, week_day integer, day_time integer, filename text,
#   have_file integer)

def s2hms(x)
    s = pad2(x % 60)
    m = pad2(( x / 60 ) % 60)
    h = x / (60*60)
    return "#{h}:#{m}:#{s}"
end

def pad2(x)
    return pad(x,2)
end

def pad(x, n)
    return "%0#{n}d" % x
end

def assert(x)
    if not x
        return 1/0
    end
end

